<template>
	<view class="PLR_2">
		<!-- <view class="flex_row_between bg_fff P_2 B_radius_5 MT_4">
			<view class="">
				请选择所属链
			</view>
			<view class="" @click="getPop">
				{{lian?lian:'请选择'}}
			</view>
		</view> -->
		<view class="flex_row_between bg_fff P_2 B_radius_5 MT_4">
			<view class="">
				输入或粘贴地址
			</view>
			<input class="fontS_14 textR" type="text" v-model="ads" placeholder="地址"/>
		</view>
		<view class="flex_row_between bg_fff P_2 B_radius_5 MT_4">
			<view class="">
				请输入地址昵称
			</view>
			<input class="fontS_14 textR" type="text" v-model="nickname" placeholder="昵称"/>
		</view>
		<view class="PTB_2 B_radius_5 pub_bg flex_rowC color_fff MT_4" @click="submit">
			确认添加
		</view>
		<view class="color_gray fontS_12 PT_2" >
			温馨提示
		</view>
		
		<uni-popup ref="popup" type="bottom">
			<view class="W_100vw bg_fff BT_radius_10 PTB_4 PLR_4">
				<view class="line_bom PTB_2 flex_rowC" v-for="(item,i) in lianList" :key='i' @click="lianChange(item)">
					{{item}}
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lian:'TRC20',
				id:'',
				lianList:[],
				lianInfo:{},
				ads:'',
				nickname:'',
				flag:false,
				cId:''
			}
		},
		onLoad(options) {
			this.id = options.id;
			this.cId = options.mId;
			if(options.mId=='edit'){
				this.flag = true;
			}else{
				this.flag = false;
			}
			// this.getDet();
		},
		methods: {
			submit(){
				let _this = this;
				if(!this.lian){
					this.toast('请选择所属链');
				}else if(!this.ads){
					this.toast('提币地址不能为空');
				}else if(!this.nickname){
					this.toast('地址昵称不能为空');
				}else{
					let params = {
						currency_id:this.id,
						nickname:this.nickname,
						address:this.ads,
						chain:this.lian
					};
					this.$req('taddress/create',params,function(res){
						if(res.code==1){
							_this.toast('添加成功');
							setTimeout(res=>{
								// if(_this.flag){
									uni.redirectTo({
										url:'./bilist2'
									})
									// ({
									// 	// url:'./moneys?id='+_this.cId+'&curreyid='+_this.id,
										
									// })
								// }else{
								// 	uni.navigateTo({
								// 		url:'./bilist'
								// 	})
								// }
								
							},500)
						}else{
							_this.toast(res.msg)
						}
					})
				}
				
				
			},
			lianChange(item){
				this.lian = item;
				this.$refs.popup.close();
			},
			getDet(){
				let _this = this;
				this.$req('account/show',{id:_this.cId},function(res){
					if(res.code==1){
						_this.lianInfo = res.data;
						_this.lianList = _this.lianInfo.currency.chain_arr;
					}else{
						_this.toast(res.msg)
					}
				})
			},
			getPop(){
				this.$refs.popup.open();
			}
		}
	}
</script>

<style>

</style>
